package com.example.abstract_factory;

import com.example.abstract_factory.entity.TVInfo;
import com.example.abstract_factory.factory.AppliancesFactory;
import com.example.abstract_factory.factory.impl.HairFactory;
import com.example.abstract_factory.service.Freezer;
import com.example.abstract_factory.service.TV;
import lombok.Data;

@Data
public class Client {

    // 这是产品的定义
    private TV tv;

    // 这是产品的定义
    private Freezer freezer;


    public Client(AppliancesFactory appliancesFactory) {

        this.tv = appliancesFactory.createTv();
        this.freezer = appliancesFactory.createFreezer();
    }


    public static void main(String[] args) {
        //new 了一个海尔的工厂 所以创建的都是 海尔的产品
        Client client = new Client(new HairFactory());
        TV tv1 = client.getTv();
        TVInfo tvInfo = tv1.createTv();
        System.out.println("tvInfo = " + tvInfo);
    }
}
